# coding=utf8
__author__ = 'lijian'

import datetime

from utils import byteUtil
from utils import bcdUtil
import setting
from protocol.uplink.packet import *



# 终端信息
def fn_1(dataUnit):
    data = []

    data.extend(byteUtil.strToBytes(setting.termInfo["producerId"],4))
    data.extend(byteUtil.strToBytes(setting.termInfo["productId"],8))
    data.extend(byteUtil.strToBytes(setting.termInfo["softwareVersion"],4))

    data.extend(byteUtil.encodeDayMonthYear(setting.termInfo["softwareReleaseDate"]))
    data.extend(byteUtil.strToBytes(setting.termInfo["capacityCode"], 11))
    data.extend(byteUtil.strToBytes(setting.termInfo["protocolVersion"], 4))
    data.extend(byteUtil.strToBytes(setting.termInfo["hardwareVersion"], 4))
    data.extend(byteUtil.strToBytes(setting.termInfo["plcModelType"], 8))
    data.extend(byteUtil.encodeDayMonthYear(setting.termInfo["hardwareReleaseDate"]) )
    data.append(setting.termInfo["haveRelay"])
    data.append(setting.termInfo["termType"])
    data.extend(byteUtil.encodeDayMonthYear(setting.termInfo["producedDate"]) )

    du = DataUnit(pn=dataUnit.PN, fn=dataUnit.FN, data=data)
    return du